/**
 @file ctc_asw_mirror.h

 @date 2020-08-03

 @version v1.0
 This module allows network application developers to manage mirror configuration. Mirror feature allows packet or 
 flow be duplicated and capture on destination port for the purposes of debugging or sniffing.

\p
 Mirror feature allows packet or flow be duplicated and capture on destination port for the purposes of debugging
 or sniffing. The mirroring module allows network application developers to manage mirror configuration.
 \p
 \b
 According to mirror source and mirror destination on the same or different device, mirror module can provide local
 mirror, remote mirror.
 \b
 According to the packet's direction, mirror module can provide ingress mirror and egress mirror.
 Meanwhile, mirror module support mirror source based on port and ACL.
 \p
 \b
 Based on port, packet sent by the port or received by port can be duplicated to another port for debugging or
 sniffing purposes. You must enable mirror function based port by API ctc_mirror_set_port_en().
 \p
 \b
 Based on ACL, traffic through ACL will be duplicated to another port for debugging or sniffing purposes.
 You must enable mirror function based ACL by API ctc_acl_add_entry().

\S ctc_mirror.h:ctc_mirror_dest_t
*/

#ifndef _CTC_ASW_MIRROR_H
#define _CTC_ASW_MIRROR_H
#ifdef __cplusplus
extern "C" {
#endif

/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/


/****************************************************************************
 *
* Function
*
*****************************************************************************/
/**
 @brief Set mirror enable on port

 @param[in] lchip    local chip id

 @param[in] gport           global phyical port of system

 @param[in] dir             mirror direction, ingress or egress flow

 @param[in] enable          mirror enable or not on port

 @param[in] session_id      mirror session id is useless for ax

 @remark[TMA]
     Enable mirror on port. Monitoring packet input the gport or output the gport.
     \p
     1. gport: specify the mirror global source port; when source port is equal to CTC_LPORT_CPU, it means cpu mirror which miror packet to cpu or from cpu.
     \p
     2. dir:
            \p
            ingress denote monitoring packets received in this port;
            \p
            egress denote monitoring packets transmitted from this port.
     \p
     3. enable: enable or disable mirror function in this port.
     \p
     4. session_id: mirror session id is useless for ax.
     \p
 @return CTC_E_XXX
*/
extern int32
ctc_asw_mirror_set_port_en(uint8 lchip, uint32 gport, ctc_direction_t dir, bool enable, uint8 session_id);

/**
 @brief Set local mirror destination port by add session

 @param[in] lchip    local chip id

 @param[in] mirror          mirror destination information

 @remark[TMA]
     Configure the session destinations and encapsulation info, see struct ctc_mirror_dest_t:
     \p
     1. session_id:  mirror session id is useless for ax.
     \p
     2. dest_gport:  destinations.
     \p
 @return CTC_E_XXX
*/
extern int32
ctc_asw_mirror_add_session(uint8 lchip, ctc_mirror_dest_t* mirror);

/**
 @brief Remove mirror destination port by remove session

 @param[in] lchip    local chip id

 @param[in] mirror          mirror destination information

 @remark[TMA]
     Remove configure the session with the following feature:

 @return CTC_E_XXX
*/
extern int32
ctc_asw_mirror_remove_session(uint8 lchip, ctc_mirror_dest_t* mirror);

/**
 @brief Get the information of port mirror

 @param[in] lchip    local chip id

 @param[in] gport           global phyical port of system

 @param[in] dir             mirror direction, ingress or egress flow

 @param[out] enable          a return value denote whether mirror enable on port

 @param[out] session_id      asw invalid

 @remark[TMA]
     Get info about mirror source port
     \p
     1. gport: specify the mirror global source port; when source port is equal to CTC_LPORT_CPU, it means cpu mirror which miror packet to cpu or from cpu.
     \p
     2. dir:
     \p
            ingress denote monitoring packets received in this port;
            \p
            egress denote monitoring packets tranmitted from this port.
     \p
     3. enable: get enable or disable info mirror function in this port.
     \p
     4. session_id: monitoring the packets to which session, get sesson_id info; when mirror source is cpu port, the value is meaningless.

 @return CTC_E_XXX
*/
extern int32
ctc_asw_mirror_get_port_info(uint8 lchip, uint32 gport, ctc_direction_t dir, bool* enable, uint8* session_id);

/**
 @brief Initialize the mirror module

 @param[in] lchip    local chip id

 @param[in] mirror_global_cfg   mirror module global config

 @remark[TMA]
     Initialize mirror feature module, when init, having no need to give global configuration.
     When initialized, mirroring is disabled on the device.

 @return CTC_E_XXX
*/
extern int32
ctc_asw_mirror_init(uint8 lchip, void* mirror_global_cfg);

/**
 @brief De-Initialize mirror module

 @param[in] lchip    local chip id

 @remark[TMA]  User can de-initialize the mirror configuration

 @return CTC_E_XXX
*/
extern int32
ctc_asw_mirror_deinit(uint8 lchip);
#ifdef __cplusplus
}
#endif

#endif


